<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <script src="/layui/layui.js"></script>
    <script src="/js/jquery/jquery-3.5.1.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <title>注册</title>
</head>
<body>
    <form class="layui-form" STYLE="padding-left: 25%;padding-top: 10%" lay-filter="example">
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-inline">
                <input type="text" name="title"  autocomplete="off" maxlength="10" placeholder="请输入账号" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline" >
                <input type="password" name = "user_password"  maxlength="15" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-inline" >
                <input type="password" name = "con_password"  maxlength="15" placeholder="再次输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-inline" >
                <input type="text" name = "user_mail"   autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="padding-top: 20px;">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="register" id="register" style="width: 190px">注册</button>
            </div>
        </div>
    </form>


</body>

</html>
<script>
    layui.use('form', function(){
        var form = layui.form;
        var layer = layui.layer;
        form.on('submit(register)', function(data){
            var rs = JSON.stringify(data.field)
            $.ajax({
                type:"put",
                url: "/user/register",
                data:JSON.stringify(data.field),
                dataType:"json",
                contentType : "application/json; charset=utf-8",
                success: function(result){
                    layer.msg("返回成功")
                }
            });
        });
    });
</script>